package bear.download;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class Friendsread extends DefaultHandler {
	String name,createtime,category,lsid,count;
	public static int n;
	String tagName;
	public static String name1="",createtime1="",category1="",lsid1="",count1="";
	public void startDocument() throws SAXException {
		//System.out.println("````````begin````````");
		n=0;
	}

	public void endDocument() throws SAXException {
		//System.out.println("````````end````````");
	}

	public void startElement(String namespaceURI, String localName,
			String qName, Attributes attr) throws SAXException {
		tagName = localName;
		if (localName.equals("loushiitem")) {
				//获取标签的全部属性
				for (int i = 0; i < attr.getLength(); i++) {
					//System.out.println(attr.getLocalName(i) + "=" + attr.getValue(i));
			}			
		}
	}

	public void endElement(String namespaceURI, String localName, String qName)
			throws SAXException {
		//在worker标签解析完之后，会打印出所有得到的数据
		tagName = "";
		if (localName.equals("loushiitem")) {
			printout();
			n++;
		}
	}

	public void characters(char[] ch, int start, int length)
			throws SAXException {
		if (tagName.equals("name"))
			name= new String(ch, start, length);
		else if (tagName.equals("createtime"))
			createtime = new String(ch, start, length);
		else if (tagName.equals("category"))
			category = new String(ch, start, length);
		else if (tagName.equals("count"))
			count = new String(ch, start, length);
		else if (tagName.equals("lsid"))
			lsid = new String(ch, start, length);
	}

	public void printout() {
		name1=name1 + name +"$";
		createtime1=createtime1 + createtime +"$";
		category1=category1 + category +"$";
		lsid1=lsid1 + lsid +"$";
		count1=count1 + count +"$";
	}
}